#pragma once

#include <iostream>
#include <string>
#include <time.h>

std::string GetCurrTime()
{
    time_t t = time(nullptr); // time函数获取当前的时间戳

    // localtime函数通过传递参数(当前的时间戳)来获取当前的年月日时分秒等时间
    struct tm *curr_time = localtime(&t);

    char currtime[32];
    snprintf(currtime, sizeof(currtime), "%d-%d-%d %d:%d:%d", 
        curr_time->tm_year+1900,     //tm_year：当前年份-1900
        curr_time->tm_mon+1,         //tm_mon：0-11
        curr_time->tm_mday,
        curr_time->tm_hour,
        curr_time->tm_min,
        curr_time->tm_sec
    );

    return currtime;
}